package com.afiorenza.two.runnable;

import java.util.concurrent.BlockingQueue;

public class Consumer implements Runnable {
	private BlockingQueue<Long> queue;
	private long cantNumeros;

	public Consumer(long cantNumeros, BlockingQueue<Long> queue) {
		this.cantNumeros = cantNumeros;
		this.queue = queue;
	}

	@Override
	public void run() {
		System.out.println("Consumiendo cola");

		for (int i = 0; i < cantNumeros; i++) {
			try {
				long next = queue.take();
				System.out.println("Siguiente Entero: " + next);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}